User defined Function in Apache Spark